<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Maven vs Gradle：Java构建工具深度对比</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        
        .feature-icon {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        
        .code-block {
            background: #1e1e1e;
            border-radius: 12px;
            overflow: hidden;
            position: relative;
        }
        
        .code-header {
            background: #2d2d2d;
            padding: 10px 20px;
            font-size: 14px;
            color: #888;
            border-bottom: 1px solid #444;
        }
        
        pre {
            margin: 0;
            padding: 20px;
            overflow-x: auto;
            color: #d4d4d4;
            font-family: 'Consolas', 'Monaco', monospace;
            font-size: 14px;
            line-height: 1.6;
        }
        
        .comparison-table {
            background: white;
            border-radius: 16px;
            overflow: hidden;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        }
        
        .comparison-table th {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            font-weight: 600;
            padding: 16px;
            text-align: left;
        }
        
        .comparison-table td {
            padding: 16px;
            border-bottom: 1px solid #f0f0f0;
        }
        
        .comparison-table tr:last-child td {
            border-bottom: none;
        }
        
        .section-title {
            position: relative;
            display: inline-block;
            margin-bottom: 2rem;
        }
        
        .section-title::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 0;
            width: 60px;
            height: 4px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
            color: white;
            padding: 20px 30px;
            border-radius: 12px;
            margin: 20px 0;
            font-weight: 500;
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 30px 0;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 8px;
            margin-top: -8px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-family: 'Noto Serif SC', serif;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6 text-center">
            <h1 class="text-5xl md:text-6xl font-bold mb-6">Maven vs Gradle</h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90">Java构建工具的终极对决</p>
            <div class="flex justify-center space-x-8 text-lg">
                <div class="flex items-center">
                    <i class="fas fa-cube mr-2"></i>
                    <span>深度对比</span>
                </div>
                <div class="flex items-center">
                    <i class="fas fa-rocket mr-2"></i>
                    <span>性能分析</span>
                </div>
                <div class="flex items-center">
                    <i class="fas fa-lightbulb mr-2"></i>
                    <span>选型建议</span>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12">
        <!-- Introduction -->
        <section class="bg-white rounded-2xl shadow-xl p-8 mb-12">
            <p class="text-lg leading-relaxed text-gray-700">
                <span class="drop-cap">在</span>Java 生态中，Maven 和 Gradle 是两种最流行的构建工具。Maven 以其稳定性和插件丰富度著称，而 Gradle 以其灵活性和高性能受到青睐。那么，在实际项目中该如何选择呢？
            </p>
        </section>

        <!-- Tool Overview -->
        <section class="mb-16">
            <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">1. Maven 和 Gradle</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <!-- Maven Card -->
                <div class="bg-white rounded-2xl shadow-lg p-8 card-hover">
                    <div class="flex items-center mb-6">
                        <div class="w-16 h-16 bg-orange-100 rounded-full flex items-center justify-center mr-4">
                            <i class="fab fa-java text-3xl text-orange-600"></i>
                        </div>
                        <h3 class="text-2xl font-bold text-gray-800">什么是 Maven？</h3>
                    </div>
                    <p class="text-gray-600 mb-6 leading-relaxed">
                        Maven 是 Apache 组织开发的构建工具，采用 XML 作为配置文件格式，基于"约定优于配置"原则，提供了标准化的项目管理方式。
                    </p>
                    <div class="space-y-3">
                        <div class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                            <div>
                                <strong class="text-gray-800">依赖管理</strong>
                                <p class="text-gray-600 text-sm">基于中央仓库（Maven Central），支持传递性依赖管理</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                            <div>
                                <strong class="text-gray-800">生命周期管理</strong>
                                <p class="text-gray-600 text-sm">提供 clean、compile、test、package、install、deploy 等默认生命周期</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                            <div>
                                <strong class="text-gray-800">插件生态</strong>
                                <p class="text-gray-600 text-sm">拥有丰富的插件库，可扩展性强</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                            <div>
                                <strong class="text-gray-800">结构化项目管理</strong>
                                <p class="text-gray-600 text-sm">提供统一的项目目录结构和构建方式</p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Gradle Card -->
                <div class="bg-white rounded-2xl shadow-lg p-8 card-hover">
                    <div class="flex items-center mb-6">
                        <div class="w-16 h-16 bg-purple-100 rounded-full flex items-center justify-center mr-4">
                            <i class="fas fa-cogs text-3xl text-purple-600"></i>
                        </div>
                        <h3 class="text-2xl font-bold text-gray-800">什么是 Gradle？</h3>
                    </div>
                    <p class="text-gray-600 mb-6 leading-relaxed">
                        Gradle 是一个基于 Groovy（或 Kotlin DSL）的现代化构建工具，相比 Maven 更加灵活和高效。
                    </p>
                    <div class="space-y-3">
                        <div class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                            <div>
                                <strong class="text-gray-800">增量构建</strong>
                                <p class="text-gray-600 text-sm">只编译和执行修改过的部分，提升构建速度</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                            <div>
                                <strong class="text-gray-800">并行执行</strong>
                                <p class="text-gray-600 text-sm">支持任务并行执行，充分利用多核 CPU</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                            <div>
                                <strong class="text-gray-800">灵活的 DSL</strong>
                                <p class="text-gray-600 text-sm">基于 Groovy/Kotlin DSL，配置更加简洁</p>
                            </div>
                        </div>
                        <div class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                            <div>
                                <strong class="text-gray-800">丰富的插件</strong>
                                <p class="text-gray-600 text-sm">提供类似 Maven 的插件机制，支持自定义任务</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Configuration Comparison -->
        <section class="mb-16">
            <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">2. 配置方式对比</h2>
            <p class="text-gray-600 mb-8">Maven 使用 XML 进行配置，而 Gradle 使用 Groovy/Kotlin DSL，示例如下：</p>
            
            <div class="grid md:grid-cols-2 gap-8">
                <!-- Maven Config -->
                <div>
                    <h3 class="text-xl font-bold text-gray-800 mb-4">2.1 Maven 配置（pom.xml）</h3>
                    <div class="code-block">
                        <div class="code-header">
                            <i class="fas fa-file-code mr-2"></i>pom.xml
                        </div>
                        <pre><code>&lt;project&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;com.ts&lt;/groupId&gt;
  &lt;artifactId&gt;demo-project&lt;/artifactId&gt;
  &lt;version&gt;1.0.0&lt;/version&gt;
  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
      &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
      &lt;version&gt;5.3.10&lt;/version&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;
&lt;/project&gt;</code></pre>
                    </div>
                </div>

                <!-- Gradle Config -->
                <div>
                    <h3 class="text-xl font-bold text-gray-800 mb-4">2.2 Gradle 配置（build.gradle）</h3>
                    <div class="code-block">
                        <div class="code-header">
                            <i class="fas fa-file-code mr-2"></i>build.gradle
                        </div>
                        <pre><code>plugins {
    id 'java'
}

group = 'com.ts'
version = '1.0.0'

dependencies {
    implementation 'org.springframework:spring-core:5.3.10'
}</code></pre>
                    </div>
                </div>
            </div>
            
            <div class="highlight-box mt-8">
                <i class="fas fa-lightbulb mr-2"></i>
                Gradle 的 DSL 语法比 Maven 的 XML 更加简洁，易读性和可维护性更强。
            </div>
        </section>

        <!-- Dependency Management -->
        <section class="mb-